﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GP.Logic;
using GP.Logic.Model;
using System.Data.EntityClient;
using System.Data.EntityModel;
using System.Data.Entity.Infrastructure;
using System.Data.Entity;


namespace WebForms.Doctor
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var gp = new GpContext();
                GpSysUser gpSysUser = gp.GpSysUsers.Single(a => a.Username == User.Identity.Name);
                gp.Citizens.Where(a => a.DocId == gpSysUser.DocId).OrderBy(a => a.Name).Load();
                gvCitizens.DataSource = gp.Citizens.Local;
                gvCitizens.DataBind();

                gp.GrantedAccessTos.Where(a => a.DocId == gpSysUser.DocId).OrderBy(a => a.Expires).Load();
                //CitGrantedTo.DataSource = gp.Citizens.Local;
                CitGrantedTo.DataSource = gp.GrantedAccessTos.Local;
                CitGrantedTo.DataBind();
            }
        }
    }
}